<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />

<div class="t_bar">
	<span class="color_red">*</span>仪器设备购置（或自制）清单
</div>
	<table  id="eq_table1" cellpadding="0" class="t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
				<col style="width: 5%"/>
				<col style="width: 5%"/>
				<col style="width: 10%"/>
				<col style="width: 10%"/>
				<col style="width: 10%"/>
				<col style="width: 5%"/>
				<col style="width: 10%"/>
				<col style="width: 10%"/>
				<col style="width: 10%"/>
				<col style="width: 15%"/>
				<col style="width: 10%"/>
			<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center">选择</th>
						<th class="TblHead" align="center">序号</th>
						<th class="TblHead" align="center">设备名称</th>
						<th class="TblHead" align="center">型号/规格</th>
						<th class="TblHead" align="center">单价（万元）</th>
						<th class="TblHead" align="center">数量</th>
						<th class="TblHead" align="center"> 金额（万元）</th>
						<th class="TblHead" align="center"> 凭证号</th>
						<th class="TblHead" align="center"> 研发用途</th>
						<th class="TblHead" align="center"> 购买年月</th>
						<th class="TblHead" align="center"> 备注</th>
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none">
						<td align="center">
							<input type="radio" style="border: 0px;background-color: white;" class="radiobutton" name="selMileStones" >
						</td>
						<td align="center">
							<span name="equipments|equipment[0]@seq_no" >[index]</span> 
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|sname" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="设备名称" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|eq_type" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="型号/规格" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|price_each" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1 required maxlength:50 " style="width:80%; text-align: right;" label="单价" onchange="count();" value="" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|eq_num" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1 required maxlength:50" style="width:20px;text-align: right;" label="数量" value="" onchange="count();" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|price_total" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1  maxlength:50 gray"  disabled="disabled" style="width:80%; text-align: right;" label="金额" value="" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|depend_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="凭证号" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|use_way" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="研发用途" value="" maxlength="50"/>
						</td>
						<td align="center">
							<cpt:date id="equipment_buy_date_[0]" name="equipments|equipment[0]|buy_date" label="购买年月" value="" className=" required  date  "  size="8" ></cpt:date>
						</td>
						<td align="center">
							<input type="text" name="equipments|equipment[0]|others" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="备注" value="" maxlength="50"/>
						</td>
					</tr>
					
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/equipments/equipment" var="equipment">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr >
						<td align="center">
							<input type="radio" style="border: 0px;background-color: white;" class="radiobutton" name="selMileStones" >
						</td>
						<td align="center">
							<span   name="equipments/equipment[${flag}${index}]@seq_no" ><x:out select="$equipment/@seq_no"/></span> 
						</td>
						
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/sname" value="<x:out select="$equipment/sname" />" class="hn_iuput_kuang required maxlength:50" style="width:80%" label="设备名称 " maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/eq_type" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="型号/规格" value="<x:out select="$equipment/eq_type"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/price_each" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1 required maxlength:50 " style="width:80%; text-align: right;" label="单价" onchange="count();" value="<x:out select="$equipment/price_each"/>" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/eq_num" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1 required maxlength:50" style="width:20px;text-align: right;" label="数量" value="<x:out select="$equipment/eq_num"/>" onchange="count();" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/price_total" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1  maxlength:50 gray" style="width:80%; text-align: right;" label="金额" disabled="disabled" value="<x:out select="$equipment/price_total"/>" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/depend_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="凭证号" value="<x:out select="$equipment/depend_num"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/use_way" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="研发用途" value="<x:out select="$equipment/use_way"/>" maxlength="50"/>
						</td>
						<td align="center">
							<c:set var="buy_date"><x:out select="$equipment/buy_date"/></c:set>
							<cpt:date id="equipment_buy_date_[${flag}${index}]" name="equipments/equipment[${flag}${index}]/buy_date" label="购买年月" value="${buy_date }" className=" required  date  "  size="8" ></cpt:date>
						</td>
						<td align="center">
							<input type="text" name="equipments/equipment[${flag}${index}]/others" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="备注" value="<x:out select="$equipment/others"/>" maxlength="50"/>
						</td>
					
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					<script type="text/javascript">
						showAllDateTag("eq_table1");
					</script>
					</x:forEach>
				</tbody>
					</table>
					<table id="total1" class="t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
						<col style="width: 5%"/>
						<col style="width: 5%"/>
						<col style="width: 10%"/>
						<col style="width: 10%"/>
						<col style="width: 10%"/>
						<col style="width: 5%"/>
						<col style="width: 10%"/>
						<col style="width: 10%"/>
						<col style="width: 10%"/>
						<col style="width: 15%"/>
						<col style="width: 10%"/>
						<tr>
							<td align="right" colspan="2">合计：</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">
								<input type="text" name="equipments/total_num1" id="total_num1" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1 maxlength:50 gray" style="width:20px;text-align: right; "  disabled="disabled" value="<x:out select="$xmlData/data/equipments/total_num1"/>"  />
							</td>
							<td align="center">
								<input type="text" name="equipments/total_price1" id="total_price1" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1 maxlength:50 gray" style="width:80%; text-align: right;"  disabled="disabled" value="<x:out select="$xmlData/data/equipments/total_price1"/>"  />
							</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
						</tr>
					
					</table>
					
					<p>备注：自制仪器设备请在此表中填写自制成套仪器设备名称、型号/规格，金额填写成本价</p>
					<table width="98%" align="center">
							<tr >
								<td>
									<input class="button_02" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('eq_table1',999,'仪器设备购置（或自制）清单内容最多只能填写999条')){addNewRow('eq_table1');showDateTag('eq_table1');}try{top.resizeFrame();}catch(e){};changeCss();count()">
									<input class="button_02" name="cmdMovePrev" type=button value="上移" onclick="movePrev('eq_table1','selMileStones');changeCss()">
									<input class="button_02" name="cmdMoveNext" type=button value="下移" onclick="moveNext('eq_table1','selMileStones');changeCss()">
									<input class="button_02" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('eq_table1','条仪器设备购置（或自制）清单内容');changeCss();count()">
								</td>
							</tr>
					</table>
					<br/>
					
<div class="t_bar">
	企业自制仪器设备零部件购置清单<input type="hidden" id="eq_tab2_val" name="equipment2s/eq_tab2_val" value="<x:out select="$xmlData/data/equipment2s/eq_tab2_val"/>">
</div>
	<table  id="eq_table2" cellpadding="0" class="t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
		<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center"  width="5%">选择</th>
						<th class="TblHead" align="center"  width="5%">序号</th>
						<th class="TblHead" align="center"  width="10%">零部件名称</th>
						<th class="TblHead" align="center"  width="10%">型号/规格</th>
						<th class="TblHead" align="center"   width="9%" >单价（万元）</th>
						<th class="TblHead" align="center"   width="5%" >数量</th>
						<th class="TblHead" align="center"   width="9%"> 金额（万元）</th>
						<th class="TblHead" align="center"   width="8%"> 发票号</th>
						<th class="TblHead" align="center"   width="8%"> 凭证号</th>
						<th class="TblHead" align="center"   width="10%"> 零部件用途</th>
						<th class="TblHead" align="center"   width="13%"> 购买时间</th>
						<th class="TblHead" align="center"   width="8%"> 备注</th>
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none">
						<td align="center">
							<input type="radio" style="border: 0px;background-color: white;" class="radiobutton" name="selMileStones" >
						</td>
						<td align="center">
							<span name="equipment2s|equipment2[0]@seq_no" >[index]</span> 
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|sname" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="零部件名称" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|eq_type" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="型号/规格" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|price_each" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1 required maxlength:50 " style="width:80%; text-align: right;" label="单价" onchange="count();" value="" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|eq_num" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1 required maxlength:50" style="width:20px;text-align: right;" label="数量" onchange="count();" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|price_total" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1  maxlength:50 gray" style="width:80%; text-align: right;" label="金额" disabled="disabled" value="" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|depend1_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="发票号" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|depend_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="凭证号" value="" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|use_way" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="零部件用途" value="" maxlength="50"/>
						</td>
						<td align="center">
							<cpt:date id="equipment2_buy_date_[0]" name="equipment2s|equipment2[0]|buy_date" label="购买时间" value="" className=" required  date  "  size="8" ></cpt:date>
						</td>
						<td align="center">
							<input type="text" name="equipment2s|equipment2[0]|others" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="备注" value="" maxlength="50"/>
						</td>
					</tr>
					
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/equipment2s/equipment2" var="equipment2">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr >
						<td align="center">
							<input type="radio" style="border: 0px;background-color: white;" class="radiobutton" name="selMileStones" >
						</td>
						<td align="center">
							<span   name="equipment2s/equipment2[${flag}${index}]@seq_no" ><x:out select="$equipment2/@seq_no"/></span> 
						</td>
						
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/sname" value="<x:out select="$equipment2/sname" />" class="hn_iuput_kuang required maxlength:50" style="width:80%" label="零部件名称 " maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/eq_type" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="型号/规格" value="<x:out select="$equipment2/eq_type"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/price_each" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1 required maxlength:50 " style="width:80%; text-align: right;" label="单价" onchange="count();" value="<x:out select="$equipment2/price_each"/>" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/eq_num" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1 required maxlength:50" style="width:20px;text-align: right;" label="数量" onchange="count();" value="<x:out select="$equipment2/eq_num"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/price_total" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1  maxlength:50 gray" style="width:80%; text-align: right;" label="金额" disabled="disabled" value="<x:out select="$equipment2/price_total"/>" maxlength="50" />
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/depend1_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="发票号" value="<x:out select="$equipment2/depend1_num"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/depend_num" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="凭证号" value="<x:out select="$equipment2/depend_num"/>" maxlength="50"/>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/use_way" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="零部件用途" value="<x:out select="$equipment2/use_way"/>" maxlength="50"/>
						</td>
						<td align="center">
							<c:set var="buy_date"><x:out select="$equipment2/buy_date"/></c:set>
							<cpt:date id="equipment2_buy_date_[${flag}${index}]" name="equipment2s/equipment2[${flag}${index}]/buy_date" label="购买时间" value="${buy_date }" className=" required  date  "  size="8" ></cpt:date>
						</td>
						<td align="center">
							<input type="text" name="equipment2s/equipment2[${flag}${index}]/others" class="hn_iuput_kuang1 required maxlength:50" style="width:80%" label="备注" value="<x:out select="$equipment2/others"/>" maxlength="50"/>
						</td>
					
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					<script type="text/javascript">
						showAllDateTag("eq_table2");
					</script>
					</x:forEach>
				</tbody>
					</table>
					<table id="total2" class="t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
						<col style="width: 5%"/>
						<col style="width: 5%"/>
						<col style="width: 10%"/>
						<col style="width: 10%"/>
						<col style="width: 9%"/>
						<col style="width: 5%"/>
						<col style="width: 9%"/>
						<col style="width: 8%"/>
						<col style="width: 8%"/>
						<col style="width: 10%"/>
						<col style="width: 13%"/>
						<col style="width: 8%"/>
						<tr>
							<td align="right" colspan="2">合计：</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td>
								<input type="text" name="equipments/total_num2" id="total_num2" onfocus="InitInput.setNumber(this,3,0,0)" class="hn_iuput_kuang1  maxlength:50 gray" style="width:20px;text-align: right;"  disabled="disabled" value="<x:out select="$xmlData/data/equipments/total_num2"/>" maxlength="50" />
							</td>
							<td>
								<input type="text" name="equipments/total_price2" id="total_price2" onfocus="InitInput.setNumber(this,9,4,2)" class="hn_iuput_kuang1  maxlength:50 gray" style="width:80%; text-align: right;"  disabled="disabled" value="<x:out select="$xmlData/data/equipments/total_price2"/>" maxlength="50" />
							</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
							<td align="center">/</td>
						</tr>
					
					</table>
					<table width="98%" align="center">
							<tr >
								<td>
									<input class="button_02" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('eq_table2',999,'企业自制仪器设备零部件购置清单内容最多只能填写999条')){addNewRow('eq_table2');showDateTag('eq_table2');}try{top.resizeFrame();}catch(e){};checkTab2();changeCss();count()">
									<input class="button_02" name="cmdMovePrev" type=button value="上移" onclick="movePrev('eq_table2','selMileStones');changeCss()">
									<input class="button_02" name="cmdMoveNext" type=button value="下移" onclick="moveNext('eq_table2','selMileStones');changeCss()">
									<input class="button_02" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('eq_table2','条企业自制仪器设备零部件购置清单内容');checkTab2();changeCss();count()">
								</td>
							</tr>
					</table>
<script type="text/javascript">
	$(function() {
		count();
		changeCss();
	});
	function count() {
		$("#total_price1").val(0);
		$("#total_num1").val(0);
		var numall1=0;
		$("#eq_table1 tr:gt(1)").each(function() {
			var price_each=$(this).find("td:eq(4) input").val();
			var num=$(this).find("td:eq(5) input").val();
			if(!!!price_each){
				price_each="0";
			}
			if(!!!num){
				num="0";
			}
			$(this).find("td:eq(6) input").val(formatVal(price_each*num));
			$("#total_price1").val(formatVal(parseFloat($("#total_price1").val())+parseFloat($(this).find("td:eq(6) input").val())));
			numall1=parseFloat(numall1)+parseFloat(num);
		});
		$("#total_num1").val(numall1);
		
		
		$("#total_price2").val(0);
		$("#total_num2").val(0);
		var numall2=0;
		$("#eq_table2 tr:gt(1)").each(function() {
			var price_each=$(this).find("td:eq(4) input").val();
			var num=$(this).find("td:eq(5) input").val();
			if(!!!price_each){
				price_each="0";
			}
			if(!!!num){
				num="0";
			}
			$(this).find("td:eq(6) input").val(formatVal(price_each*num));
			$("#total_price2").val(formatVal(parseFloat($("#total_price2").val())+parseFloat($(this).find("td:eq(6) input").val())));
			numall2=parseFloat(numall2)+parseFloat(num);
		});
		$("#total_num2").val(numall2);
	}
	function formatVal(count) {
		if (!$.isNumeric(count))
		count = "0";
		count = ((parseFloat(count) * 10000) / 10000).toFixed(4);
		count = formatNumberAuto(count.toString(), 9, 4, 2);// 格式化金额
		return count;
	}
	function checkTab2() {
		if($("#eq_table2 tr").length>2){
	    	$("#eq_tab2_val").val("1");
	    }else{
	    	$("#eq_tab2_val").val("");
	    }
	}
	function changeCss() {
		$("table.t_css").each(function(){
			$(this).find("tr:even").removeClass().addClass("li_1");
			$(this).find("tr:odd").removeClass().addClass("li_2");
		});
		changeCss1("eq_table1","total1");
		changeCss1("eq_table2","total2");
	}
	function changeCss1(id1,id2) {
		if($("#"+id1+" tr:last").attr("class")=="li_1"){
			$("#"+id2+" tr").removeClass("li_1").addClass("li_2");
		}else{
			$("#"+id2+" tr").removeClass("li_2").addClass("li_1");
		}
	}
</script>										